<template>
	<page-navbar title="Game Shop" :autoBack="false" :isLeft="false">
		<template #right>
			<view class="nav_right" @click="clickMoney">
				<image src="@/static/images/shop/money_icon.png" class="money_icon" mode=""></image>
			</view>
		</template>
	</page-navbar>
	<view class="container">
		<view class="header">
			<view class="hello">Headphone</view>
			<view class="introduce">TMA Wireless</view>
		</view>
		<view class="menu_lists">
			<!-- <up-scroll-list :indicator="false"> -->
			<view class="menu_list">
				<template v-for="(item, index) in menuList" :key="index">
					<view class="menu" :class="{ cur_menu: index == curmenu_index }" @click="clickMenu(index)">
						<image class="menu_icon" :class="{ cur_menu_icon: index == curmenu_index }" src="@/static/images/shop/cur_menu_icon.png" mode=""></image>
						<view class="menu_text">
							{{ item }}
						</view>
					</view>
				</template>
			</view>
			<!-- </up-scroll-list> -->
			<view class="card_content">
				<view class="card_img" v-for="(item, index) in 12" :key="index">
					<image class="game_img" src="@/static/images/home/game.png" mode=""></image>
				</view>
			</view>
		</view>

		<up-popup :show="show" :round="30" mode="bottom" @close="show = false" @open="open" bgColor="#19191F">
			<view class="model_content">
				<view class="c_header">
					<view class="c_title">Filter</view>
					<image class="close_icon" @click="show = false" src="@/static/images/shop/close_x.png" mode=""></image>
				</view>
				<view class="card_menu">
					<view class="card_title">Category</view>
					<view class="c_menu">
						<view class="c_text" @click="clickMenu1(item)" :class="{ c_text_y: item.state }" v-for="(item, index) in menu1" :key="index">
							{{ item.title }}
						</view>
					</view>
				</view>
				<view class="card_menu2">
					<view class="card_title">Sort By</view>
					<view class="c_menu">
						<view class="c_text" @click="clickMenu2(item)" :class="{ c_text_y: item.state }" v-for="(item, index) in menu2" :key="index">
							{{ item.title }}
						</view>
					</view>
				</view>

				<view class="card_menu3">
					<view class="card_title">Price Range</view>
					<view class="input_s">
						<view class="input1">
							<up-input
								placeholder="Min Price"
								:customStyle="inputStyle"
								color="#fff"
								type="number"
								border="surround"
								:placeholderStyle="placeholderStyle"
							></up-input>
						</view>
						<view class="input1">
							<up-input
								placeholder="Max Price"
								:customStyle="inputStyle"
								color="#fff"
								type="number"
								border="surround"
								:placeholderStyle="placeholderStyle"
							></up-input>
						</view>
					</view>
				</view>
				<view class="btn">
					<up-button type="primary" color="#0ACF83" :customStyle="btnStyle" text="Apply Filter"></up-button>
				</view>
			</view>
		</up-popup>
	</view>
	
	<tabbar :current='1'></tabbar>
</template>

<script setup>
import { ref, reactive, onMounted, watch } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';

// import pageNavbar from '@/components/page-navbar.vue'

const menuList = ['Filter', 'Popularity', 'Newest', 'Most Expensive'];
const curmenu_index = ref(0);
const show = ref(false);

const menu1 = ref([
	{ title: 'Headphone', state: true },
	{ title: 'Headband', state: false },
	{ title: 'Earpads', state: false },
	{ title: 'Cable', state: false }
]);

const menu2 = ref([
	{ title: 'Popularity', state: true },
	{ title: 'Newest', state: false },
	{ title: 'Oldest', state: false },
	{ title: 'High Price', state: false },
	{ title: 'Low Price', state: false },
	{ title: 'Review', state: false }
]);

const placeholderStyle = {
	color: '#BABABA'
};

const inputStyle = {
	height: '55rpx',
	borderRadius: '20rpx'
};
const btnStyle = {
	height: '90rpx',
	borderRadius: '20rpx',
	fontSize: '32rpx',
	color: '#333',
	fontWeight: 700
};

onLoad(() => {
	uni.hideTabBar({
		animation: false
	});
});

onMounted(() => {});

const click = (item) => {
	console.log(item);
};

const clickMoney=()=>{
	uni.navigateTo({
		url:'/pages/shop/topup'
	})
}

const clickMenu = (index) => {
	console.log(index);
	curmenu_index.value = index;
	if (index == 0) {
		show.value = true;
	}
};

const clickMenu1 = (item) => {
	item.state = !item.state;
	console.log(item);
};

const clickMenu2 = (item) => {
	item.state = !item.state;
	console.log(item);
};

const open = (e) => {
	console.log(e);
};
</script>

<style lang="scss" scoped>
	.nav_right{
		.money_icon{
			height: 48rpx;
			width: 48rpx;
			display: block;
		}
	}
.container {
	background-color: #19191f;
	min-height: 100vh;
	width: 100vw;
	padding: 0 32rpx;
	box-sizing: border-box;
	overflow: hidden;
	.model_content {
		width: 100vw;
		padding: 48rpx;
		box-sizing: border-box;
		.c_header {
			display: flex;
			align-items: center;
			justify-content: space-between;
			.c_title {
				font-size: 48rpx;
				font-weight: 700;
				line-height: 72rpx;
			}
			.close_icon {
				width: 48rpx;
				height: 48rpx;
				display: block;
			}
		}
		.card_menu {
			margin-top: 70rpx;
			.card_title {
				font-size: 32rpx;
				line-height: 40rpx;
				margin-bottom: 20rpx;
			}
			.c_menu {
				display: flex;
				flex-wrap: wrap;
				align-items: center;
				.c_text {
					padding: 0 30rpx;
					background-color: rgba(10, 207, 131, 0);
					height: 50rpx;
					font-size: 28rpx;
					line-height: 50rpx;
					border-radius: 25rpx;
					margin-bottom: 20rpx;
					color: #7f7f7f;
					transition: all 0.3s ease;
					margin-right: 10rpx;
				}
				.c_text_y {
					background-color: rgba(10, 207, 131, 1);
					color: #19191f;
				}
			}
		}
		.card_menu2 {
			margin-top: 70rpx;
			.card_title {
				font-size: 32rpx;
				line-height: 40rpx;
				margin-bottom: 20rpx;
			}
			.c_menu {
				display: flex;
				flex-wrap: wrap;
				align-items: center;
				.c_text {
					padding: 0 30rpx;
					background-color: rgba(10, 207, 131, 0);
					height: 50rpx;
					font-size: 28rpx;
					line-height: 40rpx;
					border-radius: 25rpx;
					margin-bottom: 20rpx;
					color: #7f7f7f;
					transition: all 0.3s ease;
					margin-right: 24rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					height: 78rpx;
					border: 2rpx solid #7f7f7f;
					box-sizing: border-box;
					border-radius: 20rpx;
				}
				.c_text_y {
					border: 2rpx solid rgba(10, 207, 131, 1);
					background-color: rgba(10, 207, 131, 1);
					color: #19191f;
				}
			}
		}
		.card_menu3 {
			margin-top: 70rpx;
			.card_title {
				font-size: 32rpx;
				line-height: 40rpx;
				margin-bottom: 20rpx;
			}
			.input_s {
				display: flex;
				align-items: center;
				justify-content: space-between;
				.input1 {
					width: 310rpx;
					height: 90rpx;
				}
			}
		}
		.btn {
			margin-top: 70rpx;
		}
	}

	.header {
		margin-top: 76rpx;
		.hello {
			line-height: 40rpx;
			font-size: 32rpx;
		}
		.introduce {
			font-size: 48rpx;
			line-height: 64rpx;
			margin-top: 20rpx;
			font-weight: 700;
		}
	}

	.menu_lists {
		margin-top: 100rpx;
		.menu_list {
			display: flex;
			align-items: center;
			justify-content: space-between;
			.menu {
				height: 82rpx;
				display: flex;
				align-items: center;
				border-radius: 20rpx;
				font-size: 28rpx;
				line-height: 40rpx;
				transition: all 0.3s ease;
				display: flex;
				align-items: center;
				border: 2rpx solid rgba(47, 208, 128, 0);
				text-wrap: nowrap;
				box-sizing: border-box;
				// padding: 0 20rpx;
				.menu_icon {
					width: 0;
					height: 0;
					display: block;
					transition: all 0.3s ease;
					margin-right: 16rpx;
				}
				.cur_menu_icon {
					width: 40rpx;
					height: 40rpx;
				}

				&:last-child {
					margin-right: 0;
				}
			}
			// .menu:hover {
			// 	background-color: rgba(47, 208, 128, 0.33);
			// 	color: #00b31e;
			// 	border: 2px solid rgba(47, 208, 128, 0.33);
			// }
			.cur_menu {
				padding: 0 20rpx;
				border: 2px solid rgba(47, 208, 128, 0.33);
				color: #00b31e;
				background-color: rgba(47, 208, 128, 0.33);
			}
		}
		.card_content {
			margin-top: 50rpx;
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			.card_img {
				margin: 0 13rpx 20rpx 0;
				width: 220rpx;
				height: 280rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 12rpx;
				overflow: hidden;
				.game_img {
					width: 100%;
					height: 100%;
					display: block;
				}
				&:nth-child(3n) {
					margin-right: 0;
				}
			}
		}
	}
}
</style>
